package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.BScoreRule;
import com.ruoyi.system.domain.vo.BScoreRuleVo;
import com.ruoyi.system.service.BScoreRuleService;
import com.ruoyi.system.mapper.BScoreRuleMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author yangxingze
* @description 针对表【b_score_rule(评分标准表)】的数据库操作Service实现
* @createDate 2024-12-28 00:45:04
*/
@Service
public class BScoreRuleServiceImpl extends ServiceImpl<BScoreRuleMapper, BScoreRule>
    implements BScoreRuleService{

    /**
     * 根据项目id删除评分标准
     * @param projectId
     */
    @Override
    public void deleteScoreRuleByProjectId(Long projectId) {
        baseMapper.deleteScoreRuleByProjectId(projectId);
    }

    /**
     * 保存评分标准
     * @param scoreRuleList
     * @param projectId
     */
    @Override
    public void saveScoreRule(List<BScoreRuleVo> scoreRuleList, Long projectId) {
        if(ObjectUtils.isNotEmpty(scoreRuleList)){
            for(BScoreRuleVo scoreRule:scoreRuleList){
                BScoreRule bScoreRule = new BScoreRule();
                bScoreRule.setProjectId(projectId);
                bScoreRule.setName(scoreRule.getName());
                bScoreRule.setSortNo(scoreRule.getSortNo());
                bScoreRule.setCreateTime(new Date());
                this.save(bScoreRule);
            }
        }
    }
}




